#! /bin/sh

currentDir=$1

cd "$currentDir"

echo ACTIVITY LOG - Sendmail
echo

echo STEP 1. De-activating the POP server

echo Turning off POP3 in /etc/inetd.conf
sudo cp /etc/inetd.conf /etc/inetd.conf.cutsaved
sudo sed 's/pop3/##pop3/' /etc/inetd.conf.cutsaved > inetd.conf.cuttemp
sudo cp inetd.conf.cuttemp /etc/inetd.conf
rm inetd.conf.cuttemp

echo Restarting inetd process
sudo kill -HUP `head -1 /var/run/inetd.pid`
echo

echo STEP 2. De-activating Mail Services

echo Setting MAILSERVER=-NO- in /etc/hostconfig
sudo cp /etc/hostconfig /etc/hostconfig.cutsaved
sudo sed 's/MAILSERVER=-YES-/MAILSERVER=-NO-/' /etc/hostconfig.cutsaved > hostconfig.cuttemp
sudo cp hostconfig.cuttemp /etc/hostconfig
rm hostconfig.cuttemp

echo Stopping Sendmail
sudo /System/Library/StartupItems/Sendmail/Sendmail stop

echo -n 'sudo kill -TERM ' > killcmd
ps -ax | grep submit.cf | grep -v grep | awk '{printf "%d\n", $1}' >> killcmd
sh killcmd
rm killcmd

echo

echo STEP 3. ALL DONE.
echo
